package com.sunny.ynhz.model;

import android.content.Context;

import com.sunny.ynhz.api.HttpManager;
import com.sunny.ynhz.api.subscriber.ApiSubscriber;
import com.sunny.ynhz.bean.MoreLineProBlemBean;
import com.sunny.ynhz.bean.WxyyBean;
import com.sunny.ynhz.utils.SPUtil;

import rx.Observable;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

/**
 * Created by huhuan123 on 2018/8/11.
 *
 * @describe TODO
 */

public class WxyyModel {
    IProblemTypeResultView iProblemTypeResultView;
    Context context;

    public WxyyModel(IProblemTypeResultView iProblemTypeResultView, Context context) {
        this.iProblemTypeResultView = iProblemTypeResultView;
        this.context = context;

    }

    public void getWxyyModelBean(String time, String endtime, String type, String state, String riverName, int currentPage, int pageSiz) {
        HttpManager.getInstance().getWxyyProblemSandType(time, endtime, SPUtil.get("userId", "").toString(), type, state, riverName, currentPage, pageSiz).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new ApiSubscriber(context, new ApiSubscriber.HttpOnResultListener<WxyyBean>() {
            @Override
            public void onNext(WxyyBean wxyyBean) {
                iProblemTypeResultView.onSuccess(wxyyBean);

            }

            @Override
            public void onCompleted() {

            }

            @Override
            public void onError(Throwable e) {
                super.onError(e);
                iProblemTypeResultView.onFail();
            }

            @Override
            public void onstart() {
                iProblemTypeResultView.onStartLoad();

            }
        }));
    }

    public void getWxYYBean(String type) {
        HttpManager.getInstance().getMoreLineProblem(SPUtil.get("userId", "").toString(),type).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new ApiSubscriber(context, new ApiSubscriber.HttpOnResultListener<MoreLineProBlemBean>() {
            @Override
            public void onNext(MoreLineProBlemBean moreLineProBlemBean) {
                iProblemTypeResultView.onSuccess(moreLineProBlemBean);
            }

            @Override
            public void onCompleted() {

            }

            @Override
            public void onstart() {

            }
        }));
    }


}
